package entities;

import java.awt.Color;

/** The level class for both games.
 * @author Team 1
 *
 */
@SuppressWarnings("serial")
public class Level extends Entity {

	private int level = 1;		//The initial level value.
	
	/** The level's constructor.
	 * @param x : the entity's upper-left corner's x coordinate.
	 * @param y : the entity's upper-left corner's y coordinate.
	 * @param xScale : the x resize scale. If it's lower than one it reduces the images original width, increase it otherwise.
	 * @param yScale : the y resize scale. If it's lower than one it reduces the images original height, increase it otherwise.
	 */
	public Level(int x, int y, float xScale, float yScale) {
		super(x, y);
		this.width = Math.round(130 * xScale);
		this.height = Math.round(15 * yScale);
		setText("Level:" + level);
		setForeground(Color.WHITE);
		setBounds(x, y, width, height);
	}
	
	public Level(int x, int y, float xScale, float yScale, int level) {
		super(x, y);
		this.width = Math.round(130 * xScale);
		this.height = Math.round(15 * yScale);
		this.level = level;
		setText("Level:" + this.level);
		setForeground(Color.WHITE);
		setBounds(x, y, width, height);
	}
	
	/** Gets level number.
	 * @return level: level's value.
	 */
	public int getLevel() {
		return level;
	}
	
	/** Sets and shows the level number
	 * @param level : level number.
	 */
	public void setLevel(int level) {
		//If someone reach ingeter's max value, it wont add more levels.
		if(level > 0) {
			this.level = level;
			setText("Level: "+ level);
		} else {
			this.level = Integer.MAX_VALUE;
			setText("Level: " + Integer.MAX_VALUE);
		}
	}
	
	/** Return the level's width for all resolution giving the windows width divided by 1280.
	 * @param xScale : The windows horizontal proportion value.
	 * @return The value of the ball's width depending on the horizontal scale.
	 */
	public static int getWidth(float xScale) {
		return Math.round(130 * xScale);
	}
	
	/**Return the level's height for all resolution giving the windows height divided by 720.
	 * @param yScale : The windows vertical proportion value.
	 * @return The value of the ball's height depending on the vertical scale.
	 */
	public static int getHeight(float yScale) {
		return Math.round(15 * yScale);
	}
}
